{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 3-D Red Refinement\n",
    "\n",
    "It subdivides each tetrahedron in a triangulation into eight\n",
    "subtetrahedra of equal volume. The ordering of sub-tetrahedron is choosen so that recursive application to any initial tetrahedron yields elements of at most three congruence classes. Starting from a suitable ordered initial mesh (dividing one cube into six tetrahedron), `uniformrefine3` is used in `cubemesh.m` to produce a\n",
    "uniform mesh of a cube.\n",
    "\n",
    "> Note that sub-tetrahedron may not be always positive ordered. "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Refinement"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAjAAAAGkCAIAAACgjIjwAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA\nB3RJTUUH4QgBDzo6cfkO1QAAACR0RVh0U29mdHdhcmUATUFUTEFCLCBUaGUgTWF0aFdvcmtzLCBJ\nbmMuPFjdGAAAACJ0RVh0Q3JlYXRpb24gVGltZQAwMS1BdWctMjAxNyAyMzo1ODo1OLMBgTAAACAA\nSURBVHic7d17fBT19f/xs4FACIRLCLcQkEuoCth86w8QAZFgUYrl8kC0ctPaeKH6hYKKiFUwWlHR\nEmKxpYig8AUseAMtUKgPoIZv+aZYDeVmuSdcwk0ggRCBsL8/xk7T3c1mN7s7e2b29Xz4x2R3svkI\nZ3jPOTs7cbndbgEAINrior0AAABECCQAgBIEEgBABQIJAKACgQQAUIFAAgCoQCABAFQgkAAAKhBI\nAAAVCCQAgAoEEgBABQIJAKACgQQAUIFAAgCoQCABAFQgkAAAKhBIAAAVCCQAgAoEEgBABQIJAKAC\ngQQAUIFAAgCoQCABAFQgkAAAKhBIAAAVCCQAgAoEEgBABQIJAKACgQQAUIFAAgCoQCABAFQgkAAA\nKhBIAAAVCCQAgAoEEgBABQIJAKACgQQAUIFAAgCoQCABAFQgkAAAKhBIAAAVCC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nCCQAgAoEEgBABQIJAKACgQQAUIFAAgCoQCABAFQgkAAAKhBIAAAVCCQAgAoEEgBABQIJAKACgQQA\nUIFAAgCoQCABAFQgkAAAKhBIAAAVCCQAgAoEEgBABQIJAKACgQQAUIFAAgCoQCABAFQgkAAAKhBI\nAAAVCCQAgAoEEgBABQIJAKACgQQAUIFAAgCoQCABAFQgkAAAKhBIAAAVCCQAgAoEEgBABQIJAKAC\ngQQAUIFAAgCoQCABAFQgkAAAKhBIAAAVCCQAgAoEEgBABQIJAKACgQQAUIFAAgCoQCABAFQgkAAA\nKhBIAAAVCCQAgAoEEgBABQIJAKACgQQAUIFAAgCoQCABAFQgkAAAKhBIAAAVCCQAgAoEEgBABQIJ\nAKACgQQAUIFAAgCoQCABAFQgkAAAKhBIAAAVCCQAgAoEEgBABQIJAKACgQQAUIFAAgCoQCABAFQg\nkAAAKhBIAAAVCCQAgAoEEgBAhf8PPgxuMfWrVs8AAAAASUVORK5CYII=\n",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "node = [0,0,0; 1,0,0; 1,1,0; 1,1,1];\n",
    "elem = [1 2 3 4];\n",
    "figure(1); subplot(1,2,1);\n",
    "set(gcf,'Units','normal'); set(gcf,'Position',[0.25,0.25,0.5,0.5]);\n",
    "showmesh3(node,elem,[],'FaceAlpha',0.15); view([34 12]);\n",
    "findnode3(node);\n",
    "[node,elem] = uniformrefine3(node,elem);\n",
    "figure(1); subplot(1,2,2);\n",
    "showmesh3(node,elem,[],'FaceAlpha',0.15); view([34 12]);\n",
    "findnode3(node);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "After cutting the four corner, the remaining octahedron should be divided into four tetrahedron by using one of three diagonals. Here follow Bey we always use diagonal 6-9. The ordering of sub-tetrahedron is choosen so that recursive application to any initial tetrahedron yields elements of at most three congruence classes and may not be positive ordered. To get positive ordering, use `fixorder3`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "idx =\n",
      "\n",
      "     6\n",
      "     8\n",
      "\n"
     ]
    }
   ],
   "source": [
    "[tempvar,idx] = fixorder3(node,elem);\n",
    "display(idx);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The orientation of the 6-th and 8-th children has been changed by `fixorder3` which means `uniformrefine3` will produces tetrahedrons with negagives volume."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Dependence of the Initial Mesh"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAjAAAAGkCAIAAACgjIjwAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA\nB3RJTUUH4QgBEAgn6PXSMAAAACR0RVh0U29mdHdhcmUATUFUTEFCLCBUaGUgTWF0aFdvcmtzLCBJ\nbmMuPFjdGAAAACJ0RVh0Q3JlYXRpb24gVGltZQAwMi1BdWctMjAxNyAwMDowODozOYonAhkAACAA\nSURBVHic7d1rYFT1ue/xZxIgN8IlCAaIyC1yEY1YdFuIG6xaxJYaRUHE0O7txoNWKSDZyNbdAB6h\nlR4oIEcOoliQug9URaSb1FptkQgqWtKCItRwx3DHhEBISGa/WLo6nVvmPs9a6/t5tbKyZvK3fRa/\n9TyzZsbldrsFAIBkS0n2AgAAECGQAABKEEgAABUIJACACgQSAEAFAgkAoAKBBABQgUACAKhAIAEA\nVCCQAAAqEEgAABUIJACACgQSAEAFAgkAoAKBBABQgUACAKhAIAEAVCCQAAAqEEgAABUIJACACgQS\nAEAFAgkAoAKBBABQgUACAKhAIAEAVCCQAAAqEEgAABUIJACACgQSAEAFAgkAoAKBBABQgUACAKhA\nIAEAVCCQAAAqEEgAABUIJACACgQSAEAFAgkAoAKBBABQgUACAKhAIAEAVCCQAAAqEEgAAB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EEAFCBQAIAqEAgAQBUIJAAACoQSAAA\nFQgkAIAKBBIAQAUCCQCgAoEEAFCBQAIAqEAgAQBUIJAAACoQSAAAFQgkAIAKBBIAQAUCCQCgAoEE\nAFCBQAIAqEAgAQBUIJAAACoQSAAAFQgkAIAKBBIAQAUCCQCgAoEEAFCBQAIAqEAgAQBUIJAAACoQ\nSAAAFQgkAIAKBBIAQAUCCQCgAoEEAFCBQAIAqEAgAQBUIJAAACoQSAAAFQgkAIAKBBIAQAUCCQCg\nAoEEAFCBQAIAqEAgAQBUIJAAACoQSAAAFQgkAIAKBBIAQAUCCQCgAoEEAFCBQAIAqEAgAQBUIJAA\nACoQSAAAFQgkAIAKBBIAQAUCCQCgAoEEAFCBQAIAqEAgAQBUIJAAACoQSAAAFQgkAIAKBBIAQAUC\nCQCgAoEEAFCBQAIAqEAgAQBUIJAAACoQSAAAFQgkAIAKBBIAQAUCCQCgAoEEAFCBQAIAqEAgAQBU\nIJAAACoQSAAAFQgkAIAKBBIAQAUCCQCgAoEEAFCBQAIAqEAgAQBUIJAAACoQSAAAFQgkAIAKBBIA\nQAUCCQCgAoEEAFCBQAIAqEAgAQBUIJAAACoQSAAAFf4HqQoxr3m/8fMAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "node = [1,0,0; 1,1,0; 0,0,0; 1,1,1];\n",
    "elem = [1 2 3 4];\n",
    "set(gcf,'Units','normal'); set(gcf,'Position',[0.25,0.25,0.5,0.5]);\n",
    "figure(1); subplot(1,2,1);\n",
    "showmesh3(node,elem,[],'FaceAlpha',0.15); view([34 12]);\n",
    "findnode3(node);\n",
    "[node,elem] = uniformrefine3(node,elem);\n",
    "figure(1); subplot(1,2,2);\n",
    "showmesh3(node,elem,[],'FaceAlpha',0.15); view([34 12]);\n",
    "findnode3(node);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The initial mesh is still positive but after one uniform refinement the diagonal 6-9 is longer than 5-10. Therefore the refined mesh is less shape regular although\n",
    "still three congruence classes are possible. To have a better mesh quality, one may want to use the shorter one (implemented in `uniformrefine3l`). The subroutine `uniformrefine3`\n",
    "didn't compute the edge length. The mesh quality will depend on the ordering of the initial mesh. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " - Min quality 0.6230 - Mean quality 0.7011 \n",
      " - Min quality 0.6230 - Mean quality 0.6934 \n",
      " - Min quality 0.6230 - Mean quality 0.6915 \n",
      " - Min quality 0.6230 - Mean quality 0.6910 \n"
     ]
    }
   ],
   "source": [
    "node = [0,0,0; 1,0,0; 0,1,0; 0,0,1];\n",
    "elem = [1 2 3 4];\n",
    "for k = 1:4\n",
    "    [node,elem] = uniformrefine3(node,elem);\n",
    "    meshquality(node,elem);\n",
    "end"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We test the quality of meshes obtained by `uniformrefine3` for this \n",
    "initial mesh. The mean of the mesh quality is changing while the\n",
    "minimial is bounded below."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " - Min quality 0.7174 - Mean quality 0.7174 \n",
      " - Min quality 0.7174 - Mean quality 0.7174 \n",
      " - Min quality 0.7174 - Mean quality 0.7174 \n",
      " - Min quality 0.7174 - Mean quality 0.7174 \n"
     ]
    }
   ],
   "source": [
    "node = [0,0,0; 1,0,0; 1,1,0; 1,1,1];\n",
    "elem = [1 2 3 4];\n",
    "for k = 1:4\n",
    "    [node,elem] = uniformrefine3(node,elem);\n",
    "    meshquality(node,elem);\n",
    "end"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "If we use the first example, as the correct diagonal used, `min=mean` which means all elements are in the same type."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Uniform Meshes of a Cube"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " - Min quality 0.7174 - Mean quality 0.7174 \n",
      " - Min quality 0.7174 - Mean quality 0.7174 \n",
      " - Min quality 0.7174 - Mean quality 0.7174 \n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAjAAAAGkCAIAAACgjIjwAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAA\nB3RJTUUH4QgBECIRSCSLgQAAACR0RVh0U29mdHdhcmUATUFUTEFCLCBUaGUgTWF0aFdvcmtzLCBJ\nbmMuPFjdGAAAACJ0RVh0Q3JlYXRpb24gVGltZQAwMi1BdWctMjAxNyAwMDozNDoxN1LfiPQAACAA\nSURBVHic7Z1BaFxXsvcrwwfCC2MLgt4i2Bub0Soef0ZLebKwV5N8EHhmwKt5No+38IOYhxcJhuHr\nR8B4FsOQQLQYgjPmWzQ89CDw5FlJi3F6aYLjWWkYbyJmIwKRycJolW9R7kp1nXNP32615HNbv99C\nSN33drf63Fv/U3XqVL3x448/CgAAwOvmZ6/7AwAAAIggSAAAUAkIEgAAVAGCBAAAVYAgAQBAFSBI\nAABQBQgSAABUAYIEAABVgCABAEAVIEgAAFAFCBIAAFQBggQAAFWAIAEAQBUgSAAAUAUIEgAAVAGC\nBAAAVYAgAQBAFSBIAABQBQgSAABUAYIEAABVgCABAEAVIEgAAFAFCBIAAFQBggQAAFWAIAEAQBUg\nSAAAUAUIEgAAVAGCBAAAVYAgAQBAFSBIAABQBQgSAABUAYIEAABVgCABAEAVIEgAAFAFCBIAAFQB\nggQAAFWAIAEAQBUgSAAAUAUIEgAAVAGCBAAAVYAgAQBAFSBIAABQBQgSAABUAYIEAABVgCABAEAV\nIEgAAFAFCBIAAFQBggQAAFWAIAEAQBUgSAAAUAUIEgAAVAGCBAAAVYAgAQBAFSBIAABQBQgSAAB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QIAgCpAkAAAoAoQJAAAqAIECQAAqgBBAgCAKkCQAACgChAkAACoAgQJ\nAACqAEECAIAqQJAAAKAKECQAAKgCBAkAAKoAQQIAgCpAkAAAoAoQJAAAqAIECQAAqgBBAgCAKkCQ\nAACgChAkAACoAgQJAACqAEECAIAqQJAAAKAKECQAAKgCBAkAAKoAQQIAgCpAkAAAoAoQJAAAqAIE\nCQAAqgBBAgCAKkCQAACgChAkAACoAgQJAACqAEECAIAqQJAAAKAKECQAAKgCBAkAAKoAQQIAgCpA\nkAAAoAoQJAAAqAIECQAAqgBBAgCAKkCQAACgChAkAACoAgQJAACqAEECAIAqQJAAAKAKECQAAKgC\nBAkAAKoAQQIAgCpAkAAAoAoQJAAAqAIECQAAqgBBAgCAKkCQAACgChAkAACoAgQJAACqAEECAIAq\nQJAAAKAKECQAAKgCBAkAAKoAQQIAgCpAkAAAoAoQJAAAqAIECQAAqgBBAgCAKkCQAACgChAkAACo\nAgQJAACqAEECAIAqQJAAAKAKECQAAKgCBAkAAKoAQQIAgCpAkAAAoAoQJAAAqAIECQAAqgBBAgCA\nKkCQAACgChAkAACoAgQJAACqAEECAIAqQJAAAKAKECQAAKgCBAkAAKoAQQIAgCpAkAAAoAoQJAAA\nqAIECQAAqgBBAgCAKkCQAACgChAkAACoAgQJAACqAEECAIAqQJAAAKAKECQAAKgCBAkAAKoAQQIA\ngCpAkAAAoAoQJAAAqAIECQAAqgBBAgCAKkCQAACgChAkAACoAgQJAACqAEECAIAqQJAAAKAKECQA\nAKgCBAkAAKoAQQIAgCpAkAAAoAoQJAAAqIL/D9WBAZNmynqoAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "node = [-1,-1,-1; 1,-1,-1; 1,1,-1; -1,1,-1; -1,-1,1; 1,-1,1; 1,1,1; -1,1,1]; \n",
    "elem = [1 2 3 7; 1 4 3 7; 1 5 6 7; 1 5 8 7; 1 2 6 7; 1 4 8 7];\n",
    "\n",
    "figure(1); subplot(1,3,1); \n",
    "showmesh3(node,elem,[],'FaceAlpha',0.25); view([38 10]);\n",
    "meshquality(node,elem);\n",
    "\n",
    "[node,elem] = uniformrefine3(node,elem);\n",
    "figure(1); subplot(1,3,2);\n",
    "showmesh3(node,elem,[],'FaceAlpha',0.25); view([38 10]);\n",
    "meshquality(node,elem);\n",
    "\n",
    "[node,elem] = uniformrefine3(node,elem);\n",
    "figure(1); subplot(1,3,3);\n",
    "showmesh3(node,elem,[],'FaceAlpha',0.25); view([38 10]);\n",
    "meshquality(node,elem);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Starting from a suitable ordered initial mesh (dividing one cube into six tetrahedron), `uniformrefine3`, which is used in `cubemesh.m`, will produce a\n",
    "uniform mesh of a cube. In the output of mesh quality, `min = mean` means all tetrahedron are in one type. *Again the obtained tetrahedron may not be all positive ordered*. "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Test boundary flag"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "ans =\n",
      "\n",
      "     0\n",
      "\n",
      "\n",
      "ans =\n",
      "\n",
      "     0\n",
      "\n"
     ]
    }
   ],
   "source": [
    "node = [-1,-1,-1; 1,-1,-1; 1,1,-1; -1,1,-1; -1,-1,1; 1,-1,1; 1,1,1; -1,1,1]; \n",
    "elem = [1 2 3 7; 1 4 3 7; 1 5 6 7; 1 5 8 7; 1 2 6 7; 1 4 8 7];\n",
    "bdFlag = setboundary3(node,elem,'Dirichlet');\n",
    "for k = 1:2\n",
    "    [node,elem,bdFlag] = uniformrefine3(node,elem,bdFlag);\n",
    "    bdFlagnew = setboundary3(node,elem,'Dirichlet');\n",
    "    display(any(any(bdFlag - bdFlagnew)));\n",
    "end"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "`bdFlag` obtained by `uniformrefine3` is the same as `bdFlagnew` by finding boundary faces of the triangulation."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Reference\n",
    "\n",
    "- J. Bey. Simplicial grid refinement: on Freudenthal's algorithm and the\n",
    "optimal number of congruence classes. *Numer. Math.* 85(1):1--29, 2000.\n",
    "p11 Algorithm: RedRefinement3D. \n",
    "- S. Zhang. Successive subdivisions of tetrahedra and multigrid methods\n",
    "on tetrahedral meshes. *Houston J. Math.* 21, 541-556, 1995."
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Matlab",
   "language": "matlab",
   "name": "matlab"
  },
  "language_info": {
   "codemirror_mode": "octave",
   "file_extension": ".m",
   "help_links": [
    {
     "text": "MetaKernel Magics",
     "url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md"
    }
   ],
   "mimetype": "text/x-matlab",
   "name": "matlab",
   "version": "0.14.3"
  },
  "toc": {
   "colors": {
    "hover_highlight": "#DAA520",
    "navigate_num": "#000000",
    "navigate_text": "#333333",
    "running_highlight": "#FF0000",
    "selected_highlight": "#FFD700",
    "sidebar_border": "#EEEEEE",
    "wrapper_background": "#FFFFFF"
   },
   "moveMenuLeft": true,
   "nav_menu": {
    "height": "120px",
    "width": "252px"
   },
   "navigate_menu": true,
   "number_sections": false,
   "sideBar": true,
   "threshold": 4,
   "toc_cell": false,
   "toc_section_display": "block",
   "toc_window_display": true,
   "widenNotebook": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
